﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace DataAssociations.AssociationMiningAlgorithms.Helpers
{
    internal class FileWriter
    {
        internal void WriteFpGrowthResults(string path, int minConfidence,
                                           Dictionary<string, List<FrequentPattern>> generatedFrequentPatterns)
        {
            var sb = new StringBuilder();
            sb.AppendLine("Frequent patterns found by FPG algorithm for confidence of " + minConfidence + " elements");
            sb.AppendLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
            foreach (var group in generatedFrequentPatterns)
                foreach (var pattern in group.Value)
                    sb.AppendLine(string.Format("{1} pattern has a frequency of {0}", pattern.Frequency,
                                                pattern.ItemString));
            sb.AppendLine(
                "Thank you for using our soft. For more details go to http://code.google.com/p/associations-discoverer/.");
            File.WriteAllText(Path.GetTempPath() + path, sb.ToString());
        }
    }
}
